home *** CD-ROM | disk | FTP | other *** search
/ Amiga Collections: Purity / Purity #23 (1994-02-10)(Diesel)(DE)[WB].zip / Purity #23 (1994-02-10)(Diesel)(DE)[WB].adf / DesignerDemo / menudemo / MenuDemo.c < prev    next >
C/C++ Source or Header  |  1994-01-20  |  1KB  |  65 lines

  1. /* Simple demo using a Designer created file */
  2. /* Only run from CLI */
  3.  
  4. #include <menudemowin.c>
  5.  
  6. void main(void)
  7. {
  8. int done=0;
  9. ULONG class;
  10. UWORD code;
  11. struct Gadget *pgsel;
  12. struct IntuiMessage *imsg;
  13. int MenuNum;
  14. int ItemNum;
  15. if (OpenLibs()==0)
  16.     {
  17.     if (MakeImages()==0)
  18.         {
  19.         if (OpenWindowDisplayWindow()==0)
  20.             {
  21.             while (done==0)
  22.                 {
  23.                 Wait(1L << DisplayWindow->UserPort->mp_SigBit);
  24.                 imsg=GT_GetIMsg(DisplayWindow->UserPort);
  25.                 while (imsg != NULL )
  26.                     {
  27.                     class=imsg->Class;
  28.                     code=imsg->Code;
  29.                     pgsel=(struct Gadget *)imsg->IAddress; /* Only reference if it is a gadget message */
  30.                     GT_ReplyIMsg(imsg);
  31.                     switch (class)
  32.                         {
  33.                         case IDCMP_CLOSEWINDOW :
  34.                             done=1;
  35.                             break;
  36.                         case IDCMP_MENUPICK :
  37.                             printf("Menu Pick : ");
  38.                             while (code != MENUNULL)
  39.                                 {
  40.                                 printf(".");
  41.                                 MenuNum = MENUNUM(code);
  42.                                 ItemNum = ITEMNUM(code);
  43.                                 if ((MenuNum==0) && (ItemNum==4))
  44.                                     done=1;
  45.                                 code = ItemAddress( DemoMenu, code)->NextSelect;
  46.                                 }
  47.                             printf("\n");
  48.                             break;
  49.                         };
  50.                     imsg=GT_GetIMsg(DisplayWindow->UserPort);
  51.                     }
  52.                 }
  53.             CloseWindowDisplayWindow();
  54.             }
  55.         else
  56.             printf("Cannot open window.\n");
  57.         FreeImages();
  58.         }
  59.     else
  60.         printf("Cannot Make Images.\n");
  61.     }
  62. else
  63.     printf("Cannot open libraries.\n");
  64. }
  65.